function SLR=Normalize_Both(SL,SR,L_or_R)

a=sqrt(abs(SR(:,:)).^2 + abs(SL(:,:)).^2);
if L_or_R==2 % this is the original algorithm made by Keyrouz; everything is normalized to the Right
    phaseL(:,:)=atan2(imag(SL(:,:)),real(SL(:,:)));
    % %normalization
    SL1(:,:)=SL(:,:).*exp(-1i*phaseL(:,:))./a;
    SR1(:,:)=SR(:,:).*exp(-1i*phaseL(:,:))./a;
    SLR=SR1;
else %everything is normalized to the Left
    phaseR(:,:)=atan2(imag(SR(:,:)),real(SR(:,:)));
    % %normalization
    SL1(:,:)=SL(:,:).*exp(-1i*phaseR(:,:))./a;
    SR1(:,:)=SR(:,:).*exp(-1i*phaseR(:,:))./a;
    SLR = SL1;
end